<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>编辑视频</title>
<%@include file="/common/meta.jsp" %>
<%@include file="/common/validator.jsp"%>
<script type="text/javascript">
jQuery.noConflict();
</script>
<%@include file="/common/ec.jsp"%>
<%@include file="/common/dwr.jsp" %>
<script type="text/javascript" src="${ctx}/dwr/interface/CatalogDwrAction.js"></script>
<script type="text/javascript" src="${ctx}/scripts/fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="${ctx}/scripts/TabPanel/tabpanel.js"></script>
<link rel="stylesheet" type="text/css" href="${ctx}/scripts/TabPanel/css/style.css" />
<script type="text/javascript" src="${ctx}/dwr/interface/ArticleAction.js"></script>
</head>
<body onload="setCatalog()">
<s:form namespace="/admin/article" id="saveVideo" action="saveArticle" theme="simple"  validate="true" method="POST" enctype="multipart/form-data"> 
<input type="hidden" name="type" value="${type}"></input>
<div class="x-panel">
	<div class="x-panel-header">
		视频管理
	</div>
    <div class="x-toolbar">
		    &nbsp;
	</div>
    <table width="100%" border="0" cellpadding="5"
		cellspacing="1">
		<tr>
			<td><%@ include file="/common/messages.jsp"%></td>
		</tr>
	</table>
    
	<s:hidden name="model.id"/>
	<s:hidden name="model.version"/>
	<s:hidden name="model.createTime"/>
	<s:hidden name="model.updateTime"/>
	<s:hidden name="model.inputer.id"/>
	<fieldset style="margin: 10px;"><legend>编辑视频信息</legend>
	<table width="98%" border="0" align="center">
	  <tr><td>
			<table width="100%" align="center" cellpadding="2" cellspacing="1">
				<tr>
					<td width="90">
					<div align="right"><span class="font_b">所属栏目：</span></div>
					</td>
					<td width="" colspan="2">
					<table id="coloum">
						<tr id="clmTr">
							<td>
								<select id="catalogId" name="catalogId" cssClass="required"/>
								<s:hidden name="model.catalog.id" id="model.catalog.id"/>
							</td>
							<td align="right" width="140">
							<span class="prompting">*请选择该视频所属的栏目</span>
							</td>
						</tr>
					</table>
					</td>
				</tr>
				<tr>
					<td width="90" align="right">简短标题：</td>
					<td>
						<s:textfield cssStyle="background-image : url('../../images/icons/TxtRule.jpg');"
						name="model.shortTitle" theme="simple" size="70" id="model.shortTitle" maxlength="170" cssClass="required"/>&nbsp;<font
						color="red">*</font><span class="prompting">简短标题为页面显示标题</span>
					</td>
				</tr>
				<tr>
					<td width="90" align="right">完整标题：</td>
					<td>
						<s:textfield name="model.title" theme="simple" size="70"
						id="model.title" maxlength="250" cssClass="required"/>&nbsp;<font color="red">*</font>
					</td>
				</tr>
				<tr>
					<td width="90" align="right">副&nbsp;标&nbsp;题：</td>
					<td>
						<s:textfield name="model.subtitle" theme="simple" size="70"
						id="subtitle" maxlength="170" cssClass="required"/>&nbsp;<font color="red">*</font></td>
					</td>
				</tr>
			</table>			
	  </td></tr>
	  <tr><td>
	  		<table align="center" width="100%" cellpadding="4" cellspacing="1">
					<tr>
						<td width="90">
							<div align="right"><span class="font_b">转向链接：</span></div>
						</td>
						<td>
							<s:textfield name="model.linkUrl" onfocus="addHttp(this)" theme="simple" size="30" id="linkUrl" maxlength="255"/><span class="prompting"> *
						请填写有效的网址(如:http://www.systop.com.cn)</span></td>
						<td width="25%"></td>
					</tr>
					<tr>
						<td width="90">
							<div align="right"><span class="font_b">视频作者：</span></div>
						</td>
						<td>
							<s:textfield name="model.author" theme="simple" size="30" id="author" maxlength="100"/></td>
						<td width="18%"></td>
					</tr>
					<tr>
						<td width="90">
						<div align="right"><span class="font_b">视频简介：</span></div>
						</td>
						<td>
						<s:textarea name="model.summary" id="summary" cols="60" rows="2" ></s:textarea></td>
						<td width="18%"></td>
					</tr>
					<tr>
						<td width="90">
							<div align="right"><span class="font_b">视频属性：</span></div>
						</td>
						<td>
							<input type="checkbox" name="model.onTop" id="onTop" value="1" ${model.onTop == 1?"checked":""}/>固顶文章
							<input type="checkbox" name="model.isElite" id="isElite" value="1" ${model.isElite == 1?"checked":""} />推荐文章
							<br>&nbsp;
							<div id="flashImgDiv">
								<span class="font_b">视频海报图片：</span>
								<input type="file" id="flashImg" name="flashImg" Class="FileText" style="width:300px"/><br><br>
								<span class="font_b">已有海报图片：</span>
								<a href="${ctx}/${model.flashImg}" target="_blank">${model.flashImg}</a>
							</div>
						</td>
						<td><span class="STYLE1"></span></td>
					</tr>
				</table>
	  </td></tr>
	  <tr><td>
	  		<table align="center" width="100%">
				<tr>
					<td width="90" align="right" style="padding: 10 5 2 5;">
						<strong>视频附件</strong>
					</td>
					<td style="padding: 10 5 2 5;">
						<input type="file" name="attachments" class="FileText" style="width:300px"/>&nbsp;
					</td>
				</tr>
				<tbody id="fileUpload"></tbody>
				<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
				<tr>
					<td align="right" valign="top" width="90" style="border-top: 1px solid black; padding: 5 5 2 5;">
						<strong>已有视频附件</strong>
					</td>
					<td style="border-top: 1px solid black; padding: 5 5 2 5;">
						<c:forEach var="att" items="${model.attachmentses}">
				  	  	  <div id="attachments${att.id }">
				  	  	  <a href="${ctx}${att.path}" target="_blank">
				  	      <img src="${ctx}/images/icons/attachment.gif" />&nbsp;<font size="2">${att.name}</font>
				  	     </a>&nbsp;
				  	     <a href="#" onclick="javascript:deleteAttachment(${att.id });"><img src="${ctx}/images/icons/delete.gif"/></a>
				  	     <br><br></div>
				  	    </c:forEach>&nbsp;
				  	</td>
				</tr>
			</table>
	  </td></tr>
	</table>
	</fieldset>
	<table width="98%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
	    <td align="center">
	    	<s:if test="model.id == null">
		    <s:submit value="添加" cssClass="button"/>
		    </s:if>
			 <s:else>
      		<s:submit value="修改" cssClass="button"/>
    		</s:else>
            <s:reset value="清空" cssClass="button" onclick="clearFCK();"/>
	    </td>
	  </tr>
	</table>
</div>
</s:form>
<script type="text/javascript">
function onDisplay(){
    document.getElementById("wordNumber").style.display = "block";
}

function onHide(){
	 document.getElementById("wordNumber").style.display = "none";
}
/** set parentId */
function setCatalog(){
	CatalogDwrAction.getCatalog("catalog","1",function(catalog){
		DWRUtil.removeAllOptions("catalogId");
		DWRUtil.addOptions($("catalogId"), catalog,
    		function getValue(catalog) {
    			return catalog.id;
    		},
    		function getText(catalog) {
    			return catalog.text;
    		});
    	//设置默认栏目，用于修改时
		DWRUtil.setValue("catalogId", $('model.catalog.id').value);
		} 
	);
}

function addHttp(obj){
	if (obj.value == "" || obj.value == null) {
		obj.value = "http://";
	} 
}

function deleteAttachment(attachmentId) {
  	if (confirm("确定要删除吗？")) {
    	deleteDiv(attachmentId);
        ArticleAction.removeAttachments(attachmentId,
  	function (msg) {
  	  if (msg == 'success') {
  	    alert('删除成功！');
  	  } else if(msg == 'error') {
  	    alert('文章下存在附件不能删除。');
  	  }
  	}
  );
}
}
	function deleteDiv(attachmentId) {
		document.getElementById('attachments'+attachmentId).style.display='none'; 
		document.getElementById('attachments'+attachmentId).innerHTML=""; 
		document.getElementById('attachments'+attachmentId).removeNode(); 
	}

jQuery(document).ready(function() {
	jQuery("#saveVideo").validate();
	});
</script>
</body>
</html>
